15 research outputs found

    Eta-Expansion Does The Trick (Revised Version)

    Get PDF
    Partial-evaluation folklore has it that massaging one's source programs can make them specialize better. In Jones, Gomard, and Sestoft's recent textbook, a whole chapter is dedicated to listing such "binding-time improvements": nonstandard use of continuation passing style, eta-expansion, and a popular transformation called "The Trick". We provide a unified view of these binding-time improvements, from a typing perspective.Just as a proper treatment of product values in partial evaluationrequires partially static values, a proper treatment of disjoint sums requires moving static contexts across dynamic case expressions. This requirement precisely accounts for the nonstandard use of continuation-passing style encountered in partial evaluation. Eta-expansion thusacts as a uniform binding-time coercion between values and contexts, be they of function type, product type, or disjoint-sum type. For the latter case, it enables "The Trick".In this article, we extend Gomard and Jones's partial evaluatorfor the lambda-calculus, lambda-Mix, with products and disjoint sums; we pointout how eta-expansion for (finite) disjoint sums enables The Trick; we generalize our earlier work by identifying that eta-expansion can be obtained in the binding-time analysis simply by adding two coercion rules; and we specify and prove the correctness of our extension to lambda-Mix.Keywords: Partial evaluation, binding-time analysis, program specialization,binding-time improvement, eta-expansion, static reduction

    Towards efficient partial evaluation

    No full text
    In general, a partial evaluator needs to keep track of the tasks that have already been completed or initiated, so that it can recognize when to stop unfolding. In the MIX-style polyvariant specialization algorithm, this is accomplished by a global log. This is a very general technique, so it is not surprising that the algorithm is not particularly efficient. In many special cases a simpler technique would suffice. In this paper, we identify some classes of such special cases by considering the purpose of the global log. We outline how a partial evaluator can take advantage of these special cases and we propose analyses to detect them automatically. We discuss examples to illustrate the effect on specialization and to demonstrate that we can even obtain better residual programs. The work presented here is still in its early stages, and we do not have a full system incorporating the proposed improvements. 1 The bookkeeping of polyvariant specialization The underlying principle of the self-applicable MIX-type partial-evaluation algorithms [JSS89] is related to Jones and Mycroft’s minimal function-graphs [JM86]. Each time a procedure is called, the call is compared to a list of already processed calls (sometimes called “seen-before ” [BD91] or “déjà-vu ” [JGS93] — in MIX it is split into “Pending ” and “Out ” [Ses86]). If the current call is found in this log of calls, it is not necessary to process the procedure, and we can simply refer to the result. If it is not found, a reference is created and the call and the reference are entered in the log. Then the procedure is processed and the result is recorded under the reference. In partial evaluation, the reference is typically a freshly created name for the residual procedure. In abstract interpretation, the reference might for example be a non-terminal in a grammar [JM86]. This log is the central administrative structure in the algorithm. It ensures a smooth handling of branches, loops, and recursion in one mechanism and is the key tool for making the specialization terminate in any non-trivial cas

    On static properties of specialized programs

    No full text
    Specializing programs by partial evaluation is well defined extensionally, but in practice no intensional properties, such as what the specialized programs will look like or how they will run, can be ensured. We propose a technique for obtaining information about the intensional properties of specialized programs based only on the partial evaluator and the source program. This is useful, e.g., when the static data are not yet available, when we specialize with respect to a large number of static data and want to predict the quality of the results, or when we wish to state formal results about the family of residual programs obtained by specializing the same source program. The approach is based on a self-applicable polyvariant specializer and uses a grammargenerating abstract interpretation. This paper reports ongoing research, and the grammar-generating interpretation is only developed and proven safe for a subset of the target language. The remaining parts are outlined, but not completed. A simple example of a grammar representing a family of specialized programs is given to illustrate the approach.

    Intensions and extensions in a reflective tower

    No full text
    This article presents a model of the reflective tower based on the formal semantics of its levels. They are related extensionally by their mutual interpretation and intensionally by reification and reflection. The key points obtained here are: a formal relation between the semantic domains of each level; a formal identification of reification and reflection; the visualisation of intensional snapshots of a tower of interpreters; a formal justification and a generalization of Brown’s meta-continuation; a (structural) denotational semantics for a compositional subset of the model; the distinction between making continuations jumpy and pushy; the discovery of the tail-reflection property; and a Scheme implementation of a properly tail-reflective and single-threaded reflective tower. Section 1 presents the new approach taken here: rather than implementing reification and reflection leading to a tower, we consider an infinite tower described by the semantics of each level and relate these by reification and reflection. Meta-circularity then gives sufficient conditions for implementing it. Section 2 investigates some aspects of the environments and control in a reflective tower. An analog of the funarg problem is pointed out, in relation with the correct environment at reification time. Jumpy and pushy continuations are contrasted, and the notions of ephemeral level and proper tail-reflection are introduced. Our approach is compared with related work and after a conclusion, some issues are proposed

    Eta-expansion does the Trick

    No full text
    Reproduction of all or part of this work is permitted for educational or research use on condition that this copyright notice is included in any copy. See back inner page for a list of recent publications in the BRICS Report Series. Copies may be obtained by contacting: BRIC

    On the Idempotence of the CPS Transformation

    No full text
    The CPS (continuation-passing style) transformation on -terms has an interpretation both in programming languages, type theory, proof theory, and logic. Programming intuition suggests that it is idempotent, but this does not directly hold for all existing CPS transformations (Plotkin, Reynolds, Fischer, etc.). We rephrase it to make it syntactically idempotent, modulo j-reduction of the newly introduced continuation
    corecore